package com.jake.xpage.scheme;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.jake.xpage.router.XPageRoute;

public abstract class XPageSchemeInterceptor implements IXSchemeInterceptor {
    @Override
    public String scheme() {
        return XPageSchemeUrlGenerator.getScheme();
    }

    @Override
    public boolean handleIntercept(@NonNull String url, @Nullable Object extraObject) {
        XPageRoute route = XPageSchemeUrlGenerator.parseUrl(url);
        if (route != null) {
            route.setExtraObject(extraObject);
            return handleRoute(route);
        }
        return false;
    }

    protected abstract boolean handleRoute(@NonNull XPageRoute route);

}
